-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open Policy Agent Example #207
base: main
Are you sure you want to change the base?
Open Policy Agent Example #207
Conversation
/gcbrun |
/gcbrun |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many thanks for the sample and patience @lawrenae! 👍🏼 Do let me know if you have any queries concerning the comments I have added.
# Prerequsites | ||
|
||
* An up to date gcloud SDK installed | ||
* [opa](https://www.openpolicyagent.org/docs/latest/) installed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* [opa](https://www.openpolicyagent.org/docs/latest/) installed | |
* [opa](https://www.openpolicyagent.org/docs/latest/cli/) installed |
Tweaking url to point directly to the cli page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thoughts on adding:
brew install opa
- ref a direct link to homebrew site for folks to install opa? https://formulae.brew.sh/formula/opa
- minimum relese version to work the sample?
|
||
The goal is to use a simple HTTP web server that accepts any HTTP GET request that you issue and echoes the OPA decision back as text. OPA will fetch policy bundles from a simple bundle server. OPA, the bundle server, and the web server will be run as containers in Cloud Run. In a production environment, you likely will have a different bundle server, but it's convenient to package it together here. | ||
|
||
# Prerequsites |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Prerequsites | |
# Prerequisites |
docker push us-central1-docker.pkg.dev/<CLOUD_PROJECT>/docker/<IMAGE_NAME> | ||
``` | ||
|
||
Note: We assume Google Cloud Artifact Registry in this tutorial but any registry accessible to Cloud Run will work |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, do you mind moving this up the prereqs or in a section of required gcp apis like the sister sample https://github.com/GoogleCloudPlatform/cloud-run-samples/tree/main/multi-container/hello-nginx-sample#enable-required-apis?
* Create a custom bundle server with [Dockerfile.nginx](./Dockerfile.nginx) and [nginx.conf.template](./nginx.conf.template) with the following command: | ||
|
||
```bash | ||
docker build -f Dockerfile.nginx -t us-central1-docker.pkg.dev/<CLOUD_PROJECT>/docker/<IMAGE_NAME> . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mind replacing this with the Cloud Build equivalent? Dockerfile
can still be leveraged.
|
||
# 1. Create and push a custom bundle server image | ||
|
||
* Follow [Step 1](https://www.openpolicyagent.org/docs/latest/http-api-authorization/#1-create-a-policy-bundle) in the original tutorial, resulting in creating two files called `example.rego` and `bundle.tar.gz`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thoughts on itemizing these step by step here? It'll make the README easier to follow and the steps on the site could change later down the line without us realizing.
Hi @lawrenae! Just a friendly ping - happy to chat more about the sample. |
/gcbrun |
This is supporting material for how to create a cloud run instance where routes are authorized by Open Policy Agent.
Note: this solution includes building a custom docker container, and so part of the CI steps is using an Artifact Registry repository called
docker
in us-central1Permissions required on the cloud build service account:
Feedback most welcome!